package com.dsh.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dsh.common.response.Result;
import com.dsh.model.GoodsEntity;
import com.dsh.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @RequestMapping("findPage/{pageNum}/{pageSize}")
    public Page<GoodsEntity> findPage(@PathVariable Integer pageNum,@PathVariable Integer pageSize){
        return goodsService.findPage(pageNum,pageSize);
    }

    @RequestMapping("save")
    public Result save(@RequestBody GoodsEntity goodsEntity){
        return  goodsService.save(goodsEntity);
    }

    @RequestMapping("findById/{uname}/{id}")
    public GoodsEntity findById(@PathVariable Long id,@PathVariable String uname){
        return goodsService.findById(uname,id);
    }
}
